#!/bin/bash
#
# FTPs files from a FTP Server
# build script.
#
function saveToRemoteFile {

   FTP_SERVER=$1
   LOCAL_FILE=$2
   REMOTE_FILE=$3
   USER=$4
   PASS=$5

#   ftp -n $FTP_SERVER <<EOF 2>&1 >/tmp/cuod_ftp.log
   ftp -n $FTP_SERVER <<EOF
   if [ $? != 0 ]
	then
	return 1
   fi
user $USER $PASS
bin
put $LOCAL_FILE $REMOTE_FILE

get $REMOTE_FILE /tmp/verifyFile

quit
EOF
rm -f /tmp/processorOrderInfo
if [ -e /tmp/verifyFile ]
   then
       rm -f /tmp/verifyFile
       return 0
   else
       return 1
   fi

} # end function saveToRemoteFile

if [ "$1" = "" ]
then
   echo "Usage: saveToRemoteFile <ftp server> <local file> <remote file> <user> <password>"
   exit 1
fi

saveToRemoteFile $1 $2 $3 $4 $5
exit $?

